package com.weizhu.swufer.core.cluster;

import com.weizhu.swufer.core.client.MockServiceManager;
import com.weizhu.swufer.core.entity.InvokeParam;
import com.weizhu.swufer.core.exception.RpcBizException;
import com.weizhu.swufer.core.loadbalance.LoadBalancer;
import com.weizhu.swufer.core.exception.RpcException;
import com.weizhu.swufer.core.rpc.RpcRequest;
import com.weizhu.swufer.core.util.ClassUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;

public class FailBackMockClusterInvoker extends AbstractClusterInvoker{

    private static final Logger logger = LoggerFactory.getLogger(FailBackMockClusterInvoker.class);

    @Override
    public Object doInvoke(InvokeParam invokeParam, String address) {

        RpcRequest rpcRequest = invokeParam.getRpcRequest();
        try {
            return invokeGrpc(invokeParam, address);
        }catch (Exception e){
            logger.error("",e);
            return invokeFromMock(rpcRequest);
        }
    }




}
